<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页轮播 - 后台管理系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <link rel="stylesheet" type="text/css" href="static/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="static/css/style.css">
    <link rel="stylesheet" href="static/layui/css/layui.css"/>
</head>
<style type="text/css">
    #edui1{z-index:1 !important;}
</style>
<body>
<div class="subnav">
    <a href="">首页</a> &gt; <a href="">系统管理</a> &gt; 登陆ip修改
</div>
<div class="main-inner">
    <div class="x-body">
        <div class="layui-main">
            <form class="layui-form myform" action="?m=admin&c=ip&a=edit" method="post">
                <input type="hidden" name="m" value="{$m}" />
                <input type="hidden" name="c" value="{$c}" />
                <input type="hidden" name="a" value="{$a}" />
                <input type="hidden" name="id" value="{$data['id']}" />

                <div class="layui-form-item">
                    <label class="layui-form-label">ip：</label>
                    <div class="layui-input-inline"><input type="text" name="ip" required="true" value="{$data['ip']}" placeholder="请输入ip" autocomplete="off" class="layui-input"
                    onkeyup="this.value=value.replace(/[^\d|.]/g,'');if(this.value=='')(this.value='');"
                        ></div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>

                <div class="layui-form-item" style="z-index: 1;">
                    <label class="layui-form-label">内容：</label>
                    <div class="layui-input-inline">
                        <textarea name="describe" placeholder="请输入内容"  class="layui-textarea">{$data['describe']}</textarea>
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>

                <div class="layui-form-item">
                    <label for="" class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <a class="layui-btn" href='?m=admin&c=ip'>返回</a>
                        <button class="layui-btn" lay-submit lay-filter="go">确定</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

</body>
<script type="text/javascript" src="static/js/jquery.min.js"></script>
<script src="static/layui/layui.js" charset="utf-8"></script>
<script>
    function isValidIP(ip) {
    var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
    console.log(ip);
        return reg.test(ip);
    }
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit;

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            ip:function(value) {

                if(!isValidIP(value)){
                    return '请输入正确的ip';
                }
                var verify = null ;
                $.ajax({
                    url: "?m=admin&c=ip&a=verify"
                    ,data: {
                        "ip": value
                    }
                    ,type: "POST"
                    ,async: false
                    ,success: function(res) {
                        if(res) {
                            verify = 2;
                        }
                    }
                })
                if(verify ){
                    return '此ip已经存在';
                }
            }
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(go)', function(data){
            $(".myform").submit();
            return false;
        });
    });
</script>

</html>
